cmake_minimum_required(VERSION 2.8)
project(jf_aodgpu)

#SET(CMAKE_INSTALL_PREFIX < install_path >)

SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

add_compile_options(-std=c++11)
add_compile_options(-pthread)

find_package(OpenCV)

file(GLOB_RECURSE files_src src/*.cpp)
file(GLOB_RECURSE files_include include/*.h)

include_directories(
    ${CMAKE_CURRENT_LIST_DIR}/../${PROJECT_NAME}/include  
    ${CMAKE_CURRENT_LIST_DIR}/../jf_aodbase/include
)

message("jf_aodgpuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")

option(USE_ROS "use ros"  ON)
if(USE_ROS)
    find_package(catkin REQUIRED COMPONENTS jf_aodbase)
    catkin_package(
        INCLUDE_DIRS include
        LIBRARIES jf_aodgpu
    )
    include_directories(
        ${catkin_INCLUDE_DIRS}
    )
endif()

add_library(${PROJECT_NAME} SHARED
  ${files_src}
  ${files_include}
)

# 指定动态库版本
# VERSION 动态库版本
# SOVERSION API版本
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.1.0 SOVERSION 1)

target_link_libraries(${PROJECT_NAME}
      ${OpenCV_LIBS}
      jf_aodbase
)

if(USE_ROS)
    ADD_DEFINITIONS(-DROS) 
    catkin_add_gtest(${PROJECT_NAME}_test test/test_gpu.cpp)
    target_link_libraries(${PROJECT_NAME}_test  
    ${catkin_LIBRARIES}
        ${OpenCV_LIBS}
    )
    add_dependencies(${PROJECT_NAME}_test ${PROJECT_NAME})
else() 
    # add_executable(${PROJECT_NAME}_test test/test_gpu.cpp)
    # target_link_libraries(${PROJECT_NAME}_test  
    # ${PROJECT_NAME}
    #    ${PROJECT_NAME}
    #    cuda
    #)
    # add_dependencies(${PROJECT_NAME}_test jf_aodbase)
endif()


# install
if(USE_ROS)
    install(TARGETS ${PROJECT_NAME}
            ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
            LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
            RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
    ## Mark cpp header files for installation
    install(DIRECTORY include/
            DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
            FILES_MATCHING PATTERN "*.h")
    message("${CATKIN_PACKAGE_INCLUDE_DESTINATION}")
else()
    install(TARGETS ${PROJECT_NAME}
            DESTINATION lib)
    install(DIRECTORY include/
            DESTINATION include)
endif()